// Window.h
//

#if !defined(__MY_WINDOW_H__)
#define __MY_WINDOW_H__

#include <w32std.h>   // For RWsSession, RWindowGroup

class CWindow;
class CFbsBitmap;

/////////////////////////////////////////////////////////////////////////
////////////////////// Declaration of CWsClient /////////////////////////
/////////////////////////////////////////////////////////////////////////

// Base class for all windows
class CWsClient : public CActive
{
protected:
	//construct
	CWsClient(const TRect& aRect);

public:
	static CWsClient* NewL(const TRect& aRect);
	void ConstructL();
	// destruct
	~CWsClient();

public:
	// terminate cleanly
	void Exit();
	// active object protocol
	void IssueRequest();	// request an event
	void DoCancel();		// cancel the request

	virtual void RunL();	// handle completed request

private:
	CWsScreenDevice* iScreen;
	CWindowGc* iGc;

	CWindow *iWindow;
	
	RWsSession iWs;
	RWindowGroup iGroup;

	const TRect& iRect;

	friend class CWindow;	// needs to get at session
};




//////////////////////////////////////////////////////////////////////////////
///////////////////////// CWindow declaration ////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

class CWindow : public CBase
{
public:
	CWindow(CWsClient* aClient);
	void ConstructL (const TRect& aRect);
	~CWindow();

public:
	// access
	RWindow& Window();		// our own window
	// drawing
	void Draw(const TRect& aRect);

private:
	CWindowGc* SystemGc();	// system graphics context

private:
	RWindow iWindow;		// window server window
	TRect iRect;			// rectangle re owning window
private:
	CWsClient* iClient;		// client including session and group
	CFbsBitmap* iBitmap;
	CFbsBitmap* iBitmapMask;
};

#endif  // __MY_WINDOW_H__

